#include <cstddef>
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

#include "include/StatusEffect.h"
#include "include/entity.h"

StatusEffect::StatusEffect(StatusEffectType newType, int newDuration, int newMagnitude, Entity *newOwnerEntity)
{
    this->duration = newDuration;
    this->magnitude = newMagnitude;
    this->type = newType;
    this->ownerEntity = newOwnerEntity;
}

StatusEffect::~StatusEffect()
{
    //Nothing to see here
}

void StatusEffect::ClockTick()
{
    duration--;
}

void StatusEffect::ExecuteStatusEffects()
{

    if (type == HEALING)
    {
        int healing = magnitude;
        ownerEntity->SetHealth(ownerEntity->GetHealth() + healing);
        cout << endl << "Healing spell heals " << ownerEntity->GetName() << " for +" << healing << endl;
    }
    if (type == BURNING)
    {
        int damage = 10; //TODO CHANGE THIS
        ownerEntity->SetHealth(ownerEntity->GetHealth() - damage);
        cout << endl << "Burning damages " << ownerEntity->GetName() << " for +" << damage << endl;
    }

}

void StatusEffect::UpdateStatusEffects()
{
    duration--;
    if (duration < 1)
    {
        duration = 0;
    }
}



void StatusEffect::Display()
{
        cout <<"Status Effect: ";
        switch (type)
        {
        case FOO:
            cout << "FOO ";
            break;
        case DEFENDING:
            cout << "DEFENDING ";
            break;
        case HEALING:
            cout << "HEALING ";
            break;
        case BURNING:
            cout << "BURNING ";
            break;
        default:
            cout << "NONE ";
            break;
        }
        cout << " with magnitude " << magnitude;
        cout << " for " << duration << " more turns" << endl;
}
